<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>自定义属性</title>
</head>

<body>
  <button id="btn_del" data-id="1">删除</button>
  <button data-msg="edit">修改</button>
  <script>
    var btnDel = document.querySelector('#btn_del');
    console.log(btnDel.dataset.id);
    var btns = document.querySelectorAll('button')
    console.log(btns[1].dataset.msg);
  </script>
</body>

</html>